 ca = [];
for f = 10:1:8000
    x = log10(0.88+f/165.4) / 2.1;
    ca = [ca x];    
end
plot((ca));

figure

 cb = [];
for x_b = 0:0.01:0.8
    f_b = 165.4*((10.^(x_b*2.1))-0.88);
    cb = [cb f_b];    
end
plot((cb));


figure
f = (10:10:8000)';
greenwood = 512.18 * log(1 + f/165.4);
semilogx(f, greenwood)
%plot((greenwood));
xlabel('Frekvenie (Hz)')
ylabel('Greenwood škála')

figure
f = 1000;
erb_1k = 214 * log10(1 + f/228.8);
bark_1k = 13*atan(0.00076*f)+3.5*atan((f/7000).^2);
f = (0:1:8000)';
erb = 214 * log10(1 + f/228.8);  % very close to lyon w 245 Hz break
mel = 1127 * log(1 + f/700);
bark = 13*atan(0.00076*f) + 3.5*atan((f/7000).^2);
greenwood = 512.18 * log(1 + f/165.4);
%semilogx(f, [1000*erb/erb_1k, mel, 1000*bark/bark_1k, greenwood])
plot(f, [1000*erb/erb_1k, mel, 1000*bark/bark_1k, greenwood])
legend('ERB', 'Mel', 'Bark', 'Greenwood', 'Location', 'SouthEast')
xlabel('frequency (Hz)')
ylabel('normalized scales')


figure
f = (0:1:8000)';
mel = 1127 * log(1 + f/700);
greenwood = 512.18 * log(1 + f/165.4);
plot(f, [ mel,  greenwood])
legend( 'Mel',  'Greenwood', 'Location', 'SouthEast')
xlabel('Frekvencie (Hz)')
ylabel('Normalizovaná škála')


figure
f = 1000;
erb_1k = 214 * log10(1 + f/228.8);
f = (0:1:8000)';
erb = 214 * log10(1 + f/228.8);  % very close to lyon w 245 Hz break
mel = 1127 * log(1 + f/700);
plot(f, [1000*erb/erb_1k, mel])
legend('ERB', 'Mel',  'Location', 'SouthEast')
xlabel('Frekvencie (Hz)')
ylabel('Normalizovaná škála')

figure
f = (0:1:8000)';
mel = 1127 * log(1 + f/700);
%semilogx(f, [mel])
plot(mel);
xlabel('Frekvencie (Hz)')
ylabel('Normalizovaná škála')

figure
f = 1000;
bark_1k = 13*atan(0.00076*f)+3.5*atan((f/7000).^2);
f = (0:1:8000)';
mel = 1127 * log(1 + f/700);
bark = 13*atan(0.00076*f) + 3.5*atan((f/7000).^2);
plot(f, [ mel, 1000*bark/bark_1k])
legend('Mel', 'Bark',  'Location', 'SouthEast')
xlabel('Frekvencie (Hz)')
ylabel('Normalizovaná škála')